package cn.tedu.jewelry.mapper;


import cn.tedu.jewelry.entity.Category;
import cn.tedu.jewelry.vo.CategoryStandVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

//分类模块
@Mapper
public interface CategoryMapper {

    //添加分类
    @Insert("insert into category values(null,#{categoryName},1)")
    void insert(String categoryName);

    //删除分类
    @Delete("delete from category where id=#{id}")
    void deleteCategoryById(Long id);

    //通过id修改启用状态
    @Update("update category set enable=#{enable} where id=#{id}")
    void updateCategoryByIdAndEnable(Long id,Integer enable);

    //商品分类
    @Result(column = "category_name",property = "categoryName")
    @Select("select * from category")
    List<CategoryStandVO> getCategoryList();

    //通过id获取分类
    @Result(column = "category_name",property = "categoryName")
    @Select("select * from category where id=#{id}")
    CategoryStandVO getCategoryById(Long id);
}
